package core;

import java.io.File;
import java.io.IOException;
import java.util.*;

import fileoperation.FileCreation;
import fileoperation.FileDeletion;
import gitobject.*;
import repository.Repository;

public class JitInit {
	/**
	 * Init repository in your working area. The workTree should never be null.
	 * @param workTree the path of the jit repository
	 * @throws IOException
	 */
    public static void init(String workTree) throws IOException {
        Repository repo = new Repository(workTree);
        if(repo.exist()){
            if(repo.isDirectory()){
                System.out.println("Jit repository already exists.");
            }
            else if(repo.isFile()){
                throw new IOException(".jit is a file, please check");
            }
        }
        else {
            repo.createRepo();
            System.out.printf("Initialized empty Jit repository in %s\n", Repository.getGitDir());
        }
    }

}
